Commit d12ec596 authored by wanglei's avatar wanglei

...

parent 8217742d
/* /*
* 文件名称: SheetList.java * 文件名称: SheetList.java
* *
* 编译器: android2.2 * 编译器: android2.2
* 时间: 下午4:13:50 * 时间: 下午4:13:50
*/ */
...@@ -18,11 +18,11 @@ import android.graphics.drawable.Drawable; ...@@ -18,11 +18,11 @@ import android.graphics.drawable.Drawable;
import android.view.Gravity; import android.view.Gravity;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.HorizontalScrollView; import android.widget.HorizontalScrollView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
/** /**
*
* <p> * <p>
* <p> * <p>
* Read版本: Read V1.0 * Read版本: Read V1.0
...@@ -33,58 +33,48 @@ import android.widget.LinearLayout; ...@@ -33,58 +33,48 @@ import android.widget.LinearLayout;
* <p> * <p>
* 负责人: ljj8494 * 负责人: ljj8494
* <p> * <p>
* 负责小组: * 负责小组:
* <p> * <p>
* <p> * <p>
*/ */
public class SheetBar extends HorizontalScrollView implements OnClickListener public class SheetBar extends HorizontalScrollView implements OnClickListener {
{
public SheetBar(Context context) public SheetBar(Context context) {
{
super(context); super(context);
} }
public SheetBar(Context context, IControl control, int minimumWidth) public SheetBar(Context context, IControl control, int minimumWidth) {
{
super(context); super(context);
this.control = control; this.control = control;
this.setVerticalFadingEdgeEnabled(false); this.setVerticalFadingEdgeEnabled(false);
this.setFadingEdgeLength(0); this.setFadingEdgeLength(0);
if (minimumWidth == getResources().getDisplayMetrics().widthPixels) if (minimumWidth == getResources().getDisplayMetrics().widthPixels) {
{
this.minimumWidth = -1; this.minimumWidth = -1;
} } else {
else
{
this.minimumWidth = minimumWidth; this.minimumWidth = minimumWidth;
} }
init(); init();
} }
/** /**
*
* *
*/ */
public void onConfigurationChanged(Configuration newConfig) public void onConfigurationChanged(Configuration newConfig) {
{
sheetbarFrame.setMinimumWidth(minimumWidth == -1 ? getResources().getDisplayMetrics().widthPixels sheetbarFrame.setMinimumWidth(minimumWidth == -1 ? getResources().getDisplayMetrics().widthPixels
: minimumWidth); : minimumWidth);
} }
/** /**
* *
*/ */
private void init() private void init() {
{
Context context = this.getContext(); Context context = this.getContext();
sheetbarFrame = new LinearLayout(context); sheetbarFrame = new LinearLayout(context);
sheetbarFrame.setGravity(Gravity.BOTTOM); sheetbarFrame.setGravity(Gravity.BOTTOM);
sheetbarResManager = new SheetbarResManager(context); sheetbarResManager = new SheetbarResManager(context);
// Drawable drawable = sheetbarResManager.getDrawable(SheetbarResConstant.RESID_SHEETBAR_BG); // Drawable drawable = sheetbarResManager.getDrawable(SheetbarResConstant.RESID_SHEETBAR_BG);
...@@ -93,144 +83,129 @@ public class SheetBar extends HorizontalScrollView implements OnClickListener ...@@ -93,144 +83,129 @@ public class SheetBar extends HorizontalScrollView implements OnClickListener
// sheetbarResManager.getDrawable(SheetbarResConstant.RESID_SHEETBAR_BG); // sheetbarResManager.getDrawable(SheetbarResConstant.RESID_SHEETBAR_BG);
sheetbarFrame.setBackground(drawable); sheetbarFrame.setBackground(drawable);
sheetbarFrame.setOrientation(LinearLayout.HORIZONTAL); sheetbarFrame.setOrientation(LinearLayout.HORIZONTAL);
sheetbarFrame.setMinimumWidth(minimumWidth == -1 ? getResources().getDisplayMetrics().widthPixels sheetbarFrame.setMinimumWidth(minimumWidth == -1 ? getResources().getDisplayMetrics().widthPixels : minimumWidth);
: minimumWidth); sheetbarHeight = drawable.getIntrinsicHeight();
sheetbarHeight = drawable.getIntrinsicHeight();
drawable = sheetbarResManager.getDrawable((short) R.drawable.ss_sheetbar_shadow_left); drawable = sheetbarResManager.getDrawable((short) R.drawable.ss_sheetbar_shadow_left);
LayoutParams parmas = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); LayoutParams parmas = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
// 左边shadow // 左边shadow
View left = new View(context); View left = new View(context);
left.setBackground(drawable); left.setBackground(drawable);
sheetbarFrame.addView(left, parmas); sheetbarFrame.addView(left, parmas);
// sheetButton // sheetButton
@ SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
Vector<String> vec = (Vector<String>)control.getActionValue(EventConstant.SS_GET_ALL_SHEET_NAME, null); Vector<String> vec = (Vector<String>) control.getActionValue(EventConstant.SS_GET_ALL_SHEET_NAME, null);
drawable = sheetbarResManager.getDrawable(SheetbarResConstant.RESID_SHEETBUTTON_NORMAL_LEFT); drawable = sheetbarResManager.getDrawable(SheetbarResConstant.RESID_SHEETBUTTON_NORMAL_LEFT);
LayoutParams parmasButton = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); LayoutParams parmasButton = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
int count = vec.size(); int count = vec.size();
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++) {
{
SheetButton sb = new SheetButton(context, vec.get(i), i, sheetbarResManager); SheetButton sb = new SheetButton(context, vec.get(i), i, sheetbarResManager);
if (currentSheet == null)
{ if (currentSheet == null) {
currentSheet = sb; currentSheet = sb;
currentSheet.changeFocus(true); currentSheet.changeFocus(true);
} }
sb.setOnClickListener(this); sb.setOnClickListener(this);
sheetbarFrame.addView(sb, parmasButton); sheetbarFrame.addView(sb, parmasButton);
if (i < count - 1) if (i < count - 1) {
{
View view = new View(context); View view = new View(context);
drawable = sheetbarResManager.getDrawable(SheetbarResConstant.RESID_SHEETBAR_SEPARATOR_H); drawable = sheetbarResManager.getDrawable(SheetbarResConstant.RESID_SHEETBAR_SEPARATOR_H);
view.setBackground(drawable); view.setBackground(drawable);
sheetbarFrame.addView(view, parmasButton); sheetbarFrame.addView(view, parmasButton);
} }
} }
// 右边shadow // 右边shadow
View right = new View(context); View right = new View(context);
drawable = sheetbarResManager.getDrawable(SheetbarResConstant.RESID_SHEETBAR_SHADOW_RIGHT); drawable = sheetbarResManager.getDrawable(SheetbarResConstant.RESID_SHEETBAR_SHADOW_RIGHT);
right.setBackgroundDrawable(drawable); right.setBackgroundDrawable(drawable);
sheetbarFrame.addView(right, parmas); sheetbarFrame.addView(right, parmas);
// //
addView(sheetbarFrame, new LayoutParams(LayoutParams.WRAP_CONTENT, sheetbarHeight)); LayoutParams addLayoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, 70);
addView(sheetbarFrame, addLayoutParams);
} }
/** /**
*
* *
*/ */
public void onClick(View v) public void onClick(View v) {
{
currentSheet.changeFocus(false); currentSheet.changeFocus(false);
SheetButton sb = (SheetButton)v; SheetButton sb = (SheetButton) v;
sb.changeFocus(true); sb.changeFocus(true);
currentSheet = sb; currentSheet = sb;
control.actionEvent(EventConstant.SS_SHOW_SHEET, currentSheet.getSheetIndex()); control.actionEvent(EventConstant.SS_SHOW_SHEET, currentSheet.getSheetIndex());
} }
/** /**
* set focus sheet button(called when clicked document hyperlink) * set focus sheet button(called when clicked document hyperlink)
*
* @param index * @param index
*/ */
public void setFocusSheetButton(int index) public void setFocusSheetButton(int index) {
{ if (currentSheet.getSheetIndex() == index) {
if(currentSheet.getSheetIndex() == index)
{
return; return;
} }
int count = sheetbarFrame.getChildCount(); int count = sheetbarFrame.getChildCount();
View view = null; View view = null;
for(int i = 0; i < count; i++) for (int i = 0; i < count; i++) {
{
view = sheetbarFrame.getChildAt(i); view = sheetbarFrame.getChildAt(i);
if (view instanceof SheetButton && ((SheetButton)view).getSheetIndex() == index) if (view instanceof SheetButton && ((SheetButton) view).getSheetIndex() == index) {
{
currentSheet.changeFocus(false); currentSheet.changeFocus(false);
currentSheet = (SheetButton)view; currentSheet = (SheetButton) view;
currentSheet.changeFocus(true); currentSheet.changeFocus(true);
break; break;
} }
} }
//sheetbar scrolled //sheetbar scrolled
int screenWidth = control.getActivity().getWindowManager().getDefaultDisplay().getWidth(); int screenWidth = control.getActivity().getWindowManager().getDefaultDisplay().getWidth();
int barWidth = sheetbarFrame.getWidth(); int barWidth = sheetbarFrame.getWidth();
if(barWidth > screenWidth) if (barWidth > screenWidth) {
{
int left = view.getLeft(); int left = view.getLeft();
int right = view.getRight(); int right = view.getRight();
int off = (screenWidth - (right - left)) / 2; int off = (screenWidth - (right - left)) / 2;
off = left - off; off = left - off;
if(off < 0) if (off < 0) {
{
off = 0; off = 0;
} } else if (off + screenWidth > barWidth) {
else if(off + screenWidth > barWidth)
{
off = barWidth - screenWidth; off = barWidth - screenWidth;
} }
scrollTo(off, 0); scrollTo(off, 0);
} }
} }
/** /**
* @return Returns the sheetbarHeight. * @return Returns the sheetbarHeight.
*/ */
public int getSheetbarHeight() public int getSheetbarHeight() {
{
return sheetbarHeight; return sheetbarHeight;
} }
/** /**
* *
*/ */
public void dispose() public void dispose() {
{
sheetbarResManager.dispose(); sheetbarResManager.dispose();
sheetbarResManager = null; sheetbarResManager = null;
currentSheet = null; currentSheet = null;
if(sheetbarFrame != null) if (sheetbarFrame != null) {
{
int count = sheetbarFrame.getChildCount(); int count = sheetbarFrame.getChildCount();
View v; View v;
for(int i = 0; i < count; i++) for (int i = 0; i < count; i++) {
{
v = sheetbarFrame.getChildAt(i); v = sheetbarFrame.getChildAt(i);
if(v instanceof SheetButton) if (v instanceof SheetButton) {
{ ((SheetButton) v).dispose();
((SheetButton)v).dispose();
} }
} }
sheetbarFrame = null; sheetbarFrame = null;
......
/* /*
* 文件名称: SheetButton.java * 文件名称: SheetButton.java
* *
* 编译器: android2.2 * 编译器: android2.2
* 时间: 下午6:06:50 * 时间: 下午6:06:50
*/ */
package com.cherry.lib.doc.office.ss.sheetbar; package com.cherry.lib.doc.office.ss.sheetbar;
import android.annotation.SuppressLint;
import android.content.Context; import android.content.Context;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.util.Log;
import android.view.Gravity; import android.view.Gravity;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import androidx.core.content.ContextCompat;
import com.cherry.lib.doc.R;
/** /**
* sheet表名称按钮 * sheet表名称按钮
* <p> * <p>
...@@ -26,134 +34,144 @@ import android.widget.TextView; ...@@ -26,134 +34,144 @@ import android.widget.TextView;
* <p> * <p>
* 负责人: ljj8494 * 负责人: ljj8494
* <p> * <p>
* 负责小组: * 负责小组:
* <p> * <p>
* <p> * <p>
*/ */
public class SheetButton extends LinearLayout @SuppressLint("ViewConstructor")
{ public class SheetButton extends LinearLayout {
private static final int FONT_SIZE = 18; private static final int FONT_SIZE = 18;
// //
private static final int SHEET_BUTTON_MIN_WIDTH = 100; private static final int SHEET_BUTTON_MIN_WIDTH = 100;
/** /**
*
* @param context * @param context
*/ */
public SheetButton(Context context, String sheetName, int sheetIndex, SheetbarResManager sheetbarResManager) public SheetButton(Context context, String sheetName, int sheetIndex, SheetbarResManager sheetbarResManager) {
{
super(context); super(context);
setOrientation(HORIZONTAL); setOrientation(HORIZONTAL);
this.sheetIndex = sheetIndex; this.sheetIndex = sheetIndex;
this.sheetbarResManager = sheetbarResManager; this.sheetbarResManager = sheetbarResManager;
init(context, sheetName); init(context, sheetName);
} }
/** /**
* *
*/ */
private void init(Context context, String sheetName) private void init(Context context, String sheetName) {
{
//左边图标 //左边图标
left = new View(context); left = new View(context);
left.setBackgroundDrawable(sheetbarResManager.getDrawable(SheetbarResConstant.RESID_SHEETBUTTON_NORMAL_LEFT)); Drawable leftDrawable = sheetbarResManager.getDrawable(SheetbarResConstant.RESID_SHEETBUTTON_NORMAL_LEFT);
if (leftDrawable != null) {
Log.e("SheetButton", "leftDrawable=null");
} else {
Log.e("SheetButton", "leftDrawable!=null");
}
left.setBackgroundDrawable(leftDrawable);
addView(left); addView(left);
// //
textView = new TextView(context); textView = new TextView(context);
textView.setBackgroundDrawable(sheetbarResManager.getDrawable(SheetbarResConstant.RESID_SHEETBUTTON_NORMAL_MIDDLE)); Drawable middleDrawable =
ContextCompat.getDrawable(context, R.drawable.ss_sheetbar_button_focus_middle);
sheetbarResManager.getDrawable(SheetbarResConstant.RESID_SHEETBUTTON_NORMAL_MIDDLE);
if (middleDrawable == null) {
Log.e("SheetButton", "middleDrawable=null");
} else {
Log.e("SheetButton", "middleDrawable!=null");
}
textView.setBackgroundDrawable(middleDrawable);
textView.setText(sheetName); textView.setText(sheetName);
textView.setTextSize(FONT_SIZE); textView.setTextSize(FONT_SIZE);
textView.setGravity(Gravity.CENTER); textView.setGravity(Gravity.CENTER);
textView.setTextColor(Color.BLACK); textView.setTextColor(Color.BLACK);
int w = (int)textView.getPaint().measureText(sheetName); int w = (int) textView.getPaint().measureText(sheetName);
w = Math.max(w, SHEET_BUTTON_MIN_WIDTH); w = Math.max(w, SHEET_BUTTON_MIN_WIDTH);
addView(textView, new LayoutParams(w, LayoutParams.MATCH_PARENT)); addView(textView, new LayoutParams(w, LayoutParams.MATCH_PARENT));
// 右边图标 // 右边图标
right = new View(context); right = new View(context);
right.setBackgroundDrawable(sheetbarResManager.getDrawable(SheetbarResConstant.RESID_SHEETBUTTON_NORMAL_RIGHT)); right.setBackgroundDrawable(sheetbarResManager.getDrawable(SheetbarResConstant.RESID_SHEETBUTTON_NORMAL_RIGHT));
addView(right); addView(right);
} }
/** /**
*
* *
*/ */
public boolean onTouchEvent(MotionEvent event) public boolean onTouchEvent(MotionEvent event) {
{
int action = event.getAction(); int action = event.getAction();
switch (action) switch (action) {
{
case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_DOWN:
case MotionEvent.ACTION_MOVE: case MotionEvent.ACTION_MOVE:
if(!active) if (!active) {
{
left.setBackgroundDrawable(sheetbarResManager.getDrawable(SheetbarResConstant.RESID_SHEETBUTTON_PUSH_LEFT)); left.setBackgroundDrawable(sheetbarResManager.getDrawable(SheetbarResConstant.RESID_SHEETBUTTON_PUSH_LEFT));
textView.setBackgroundDrawable(sheetbarResManager.getDrawable(SheetbarResConstant.RESID_SHEETBUTTON_PUSH_MIDDLE)); textView.setBackgroundDrawable(sheetbarResManager.getDrawable(SheetbarResConstant.RESID_SHEETBUTTON_PUSH_MIDDLE));
right.setBackgroundDrawable(sheetbarResManager.getDrawable(SheetbarResConstant.RESID_SHEETBUTTON_PUSH_RIGHT)); right.setBackgroundDrawable(sheetbarResManager.getDrawable(SheetbarResConstant.RESID_SHEETBUTTON_PUSH_RIGHT));
} }
break; break;
case MotionEvent.ACTION_UP: case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL: case MotionEvent.ACTION_CANCEL:
if(!active) if (!active) {
{
left.setBackgroundDrawable(sheetbarResManager.getDrawable(SheetbarResConstant.RESID_SHEETBUTTON_NORMAL_LEFT)); left.setBackgroundDrawable(sheetbarResManager.getDrawable(SheetbarResConstant.RESID_SHEETBUTTON_NORMAL_LEFT));
textView.setBackgroundDrawable(sheetbarResManager.getDrawable(SheetbarResConstant.RESID_SHEETBUTTON_NORMAL_MIDDLE)); textView.setBackgroundDrawable(sheetbarResManager.getDrawable(SheetbarResConstant.RESID_SHEETBUTTON_NORMAL_MIDDLE));
right.setBackgroundDrawable(sheetbarResManager.getDrawable(SheetbarResConstant.RESID_SHEETBUTTON_NORMAL_RIGHT)); right.setBackgroundDrawable(sheetbarResManager.getDrawable(SheetbarResConstant.RESID_SHEETBUTTON_NORMAL_RIGHT));
} }
break; break;
} }
return super.onTouchEvent(event); return super.onTouchEvent(event);
} }
/** /**
* 选中或取消选中用到 * 选中或取消选中用到
*/ */
public void changeFocus(boolean gainFocus) public void changeFocus(boolean gainFocus) {
{
active = gainFocus; active = gainFocus;
left.setBackgroundDrawable(gainFocus ? sheetbarResManager.getDrawable(SheetbarResConstant.RESID_SHEETBUTTON_FOCUS_LEFT) : Log.e("SheetButton", "changeFocus=" + gainFocus);
sheetbarResManager.getDrawable(SheetbarResConstant.RESID_SHEETBUTTON_NORMAL_LEFT)); left.setBackgroundDrawable(gainFocus ?
textView.setBackgroundDrawable(gainFocus ? sheetbarResManager.getDrawable(SheetbarResConstant.RESID_SHEETBUTTON_FOCUS_MIDDLE) : sheetbarResManager.getDrawable(SheetbarResConstant.RESID_SHEETBUTTON_FOCUS_LEFT) :
sheetbarResManager.getDrawable(SheetbarResConstant.RESID_SHEETBUTTON_NORMAL_MIDDLE)); sheetbarResManager.getDrawable(SheetbarResConstant.RESID_SHEETBUTTON_NORMAL_LEFT));
right.setBackgroundDrawable(gainFocus ? sheetbarResManager.getDrawable(SheetbarResConstant.RESID_SHEETBUTTON_FOCUS_RIGHT) :
sheetbarResManager.getDrawable(SheetbarResConstant.RESID_SHEETBUTTON_NORMAL_RIGHT)); textView.setBackgroundDrawable(gainFocus ?
sheetbarResManager.getDrawable(SheetbarResConstant.RESID_SHEETBUTTON_FOCUS_MIDDLE) :
sheetbarResManager.getDrawable(SheetbarResConstant.RESID_SHEETBUTTON_NORMAL_MIDDLE));
right.setBackgroundDrawable(gainFocus ?
sheetbarResManager.getDrawable(SheetbarResConstant.RESID_SHEETBUTTON_FOCUS_RIGHT) :
sheetbarResManager.getDrawable(SheetbarResConstant.RESID_SHEETBUTTON_NORMAL_RIGHT));
} }
/** /**
* *
*/ */
public int getSheetIndex() public int getSheetIndex() {
{
return this.sheetIndex; return this.sheetIndex;
} }
/** /**
* *
*/ */
public void dispose() public void dispose() {
{
sheetbarResManager = null; sheetbarResManager = null;
left = null; left = null;
textView = null; textView = null;
right = null; right = null;
} }
private SheetbarResManager sheetbarResManager; private SheetbarResManager sheetbarResManager;
// //
private int sheetIndex;; private int sheetIndex;
;
// 左边图标 // 左边图标
private View left; private View left;
// 中间文本 // 中间文本
private TextView textView; private TextView textView;
// 右边图标 // 右边图标
private View right; private View right;
private boolean active; private boolean active;
} }
/* /*
* 文件名称: ResManager.java * 文件名称: ResManager.java
* *
* 编译器: android2.2 * 编译器: android2.2
* 时间: 上午9:39:36 * 时间: 上午9:39:36
*/ */
...@@ -8,6 +8,11 @@ package com.cherry.lib.doc.office.ss.sheetbar; ...@@ -8,6 +8,11 @@ package com.cherry.lib.doc.office.ss.sheetbar;
import android.content.Context; import android.content.Context;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.util.Log;
import androidx.core.content.ContextCompat;
import com.cherry.lib.doc.R;
/** /**
* TODO: 文件注释 * TODO: 文件注释
...@@ -21,158 +26,172 @@ import android.graphics.drawable.Drawable; ...@@ -21,158 +26,172 @@ import android.graphics.drawable.Drawable;
* <p> * <p>
* 负责人: jqin * 负责人: jqin
* <p> * <p>
* 负责小组: * 负责小组:
* <p> * <p>
* <p> * <p>
*/ */
public class SheetbarResManager public class SheetbarResManager {
{ public SheetbarResManager(Context context) {
public SheetbarResManager(Context context)
{
this.context = context; this.context = context;
ClassLoader loader = context.getClassLoader(); ClassLoader loader = context.getClassLoader();
//sheetbar background //sheetbar background
sheetbarBG = Drawable.createFromResourceStream(context.getResources(), null, sheetbarBG = Drawable.createFromResourceStream(context.getResources(), null,
loader.getResourceAsStream(SheetbarResConstant.RESNAME_SHEETBAR_BG), loader.getResourceAsStream(SheetbarResConstant.RESNAME_SHEETBAR_BG),
SheetbarResConstant.RESNAME_SHEETBAR_BG); SheetbarResConstant.RESNAME_SHEETBAR_BG);
//shadow //shadow
sheetbarLeftShadow= Drawable.createFromResourceStream(context.getResources(), null, sheetbarLeftShadow = Drawable.createFromResourceStream(context.getResources(), null,
loader.getResourceAsStream(SheetbarResConstant.RESNAME_SHEETBAR_SHADOW_LEFT), loader.getResourceAsStream(SheetbarResConstant.RESNAME_SHEETBAR_SHADOW_LEFT),
SheetbarResConstant.RESNAME_SHEETBAR_SHADOW_LEFT); SheetbarResConstant.RESNAME_SHEETBAR_SHADOW_LEFT);
sheetbarRightShadow= Drawable.createFromResourceStream(context.getResources(), null, sheetbarRightShadow = Drawable.createFromResourceStream(context.getResources(), null,
loader.getResourceAsStream(SheetbarResConstant.RESNAME_SHEETBAR_SHADOW_RIGHT), loader.getResourceAsStream(SheetbarResConstant.RESNAME_SHEETBAR_SHADOW_RIGHT),
SheetbarResConstant.RESNAME_SHEETBAR_SHADOW_RIGHT); SheetbarResConstant.RESNAME_SHEETBAR_SHADOW_RIGHT);
//hSeparator //hSeparator
hSeparator = Drawable.createFromResourceStream(context.getResources(), null, hSeparator = Drawable.createFromResourceStream(context.getResources(), null,
loader.getResourceAsStream(SheetbarResConstant.RESNAME_SHEETBAR_SEPARATOR_H), loader.getResourceAsStream(SheetbarResConstant.RESNAME_SHEETBAR_SEPARATOR_H),
SheetbarResConstant.RESNAME_SHEETBAR_SEPARATOR_H); SheetbarResConstant.RESNAME_SHEETBAR_SEPARATOR_H);
//normal state //normal state
normalLeft = Drawable.createFromResourceStream(context.getResources(), null, normalLeft =
loader.getResourceAsStream(SheetbarResConstant.RESNAME_SHEETBUTTON_NORMAL_LEFT), ContextCompat.getDrawable(context, R.drawable.ss_sheetbar_button_normal_left);
SheetbarResConstant.RESNAME_SHEETBUTTON_NORMAL_LEFT); // Drawable.createFromResourceStream(context.getResources(), null,
normalRight = Drawable.createFromResourceStream(context.getResources(), null, // loader.getResourceAsStream(SheetbarResConstant.RESNAME_SHEETBUTTON_NORMAL_LEFT),
loader.getResourceAsStream(SheetbarResConstant.RESNAME_SHEETBUTTON_NORMAL_RIGHT), // SheetbarResConstant.RESNAME_SHEETBUTTON_NORMAL_LEFT);
SheetbarResConstant.RESNAME_SHEETBUTTON_NORMAL_RIGHT); normalRight =
normalMiddle = Drawable.createFromResourceStream(context.getResources(), null, ContextCompat.getDrawable(context, R.drawable.ss_sheetbar_button_normal_right);
loader.getResourceAsStream(SheetbarResConstant.RESNAME_SHEETBUTTON_NORMAL_MIDDLE), // Drawable.createFromResourceStream(context.getResources(), null,
SheetbarResConstant.RESNAME_SHEETBUTTON_NORMAL_MIDDLE); // loader.getResourceAsStream(SheetbarResConstant.RESNAME_SHEETBUTTON_NORMAL_RIGHT),
// SheetbarResConstant.RESNAME_SHEETBUTTON_NORMAL_RIGHT);
normalMiddle =
ContextCompat.getDrawable(context, R.drawable.ss_sheetbar_button_normal_middle);
// Drawable.createFromResourceStream(context.getResources(), null,
// loader.getResourceAsStream(SheetbarResConstant.RESNAME_SHEETBUTTON_NORMAL_MIDDLE),
// SheetbarResConstant.RESNAME_SHEETBUTTON_NORMAL_MIDDLE);
//push state //push state
pushLeft = Drawable.createFromResourceStream(context.getResources(), null, pushLeft = Drawable.createFromResourceStream(context.getResources(), null,
loader.getResourceAsStream(SheetbarResConstant.RESNAME_SHEETBUTTON_PUSH_LEFT), loader.getResourceAsStream(SheetbarResConstant.RESNAME_SHEETBUTTON_PUSH_LEFT),
SheetbarResConstant.RESNAME_SHEETBUTTON_PUSH_LEFT); SheetbarResConstant.RESNAME_SHEETBUTTON_PUSH_LEFT);
pushMiddle = Drawable.createFromResourceStream(context.getResources(), null, pushMiddle =
loader.getResourceAsStream(SheetbarResConstant.RESNAME_SHEETBUTTON_PUSH_MIDDLE), ContextCompat.getDrawable(context, R.drawable.ss_sheetbar_button_push_middle);
SheetbarResConstant.RESNAME_SHEETBUTTON_PUSH_MIDDLE); // Drawable.createFromResourceStream(context.getResources(), null,
pushRight = Drawable.createFromResourceStream(context.getResources(), null, // loader.getResourceAsStream(SheetbarResConstant.RESNAME_SHEETBUTTON_PUSH_MIDDLE),
loader.getResourceAsStream(SheetbarResConstant.RESNAME_SHEETBUTTON_PUSH_RIGHT), // SheetbarResConstant.RESNAME_SHEETBUTTON_PUSH_MIDDLE);
SheetbarResConstant.RESNAME_SHEETBUTTON_PUSH_RIGHT); pushRight =
ContextCompat.getDrawable(context, R.drawable.ss_sheetbar_button_push_right);
// Drawable.createFromResourceStream(context.getResources(), null,
// loader.getResourceAsStream(SheetbarResConstant.RESNAME_SHEETBUTTON_PUSH_RIGHT),
// SheetbarResConstant.RESNAME_SHEETBUTTON_PUSH_RIGHT);
//focus state //focus state
focusLeft = Drawable.createFromResourceStream(context.getResources(), null, focusLeft =
loader.getResourceAsStream(SheetbarResConstant.RESNAME_SHEETBUTTON_FOCUS_LEFT), ContextCompat.getDrawable(context, R.drawable.ss_sheetbar_button_focus_left);
SheetbarResConstant.RESNAME_SHEETBUTTON_FOCUS_LEFT); // Drawable.createFromResourceStream(context.getResources(), null,
focusMiddle = Drawable.createFromResourceStream(context.getResources(), null, // loader.getResourceAsStream(SheetbarResConstant.RESNAME_SHEETBUTTON_FOCUS_LEFT),
loader.getResourceAsStream(SheetbarResConstant.RESNAME_SHEETBUTTON_FOCUS_MIDDLE), // SheetbarResConstant.RESNAME_SHEETBUTTON_FOCUS_LEFT);
SheetbarResConstant.RESNAME_SHEETBUTTON_FOCUS_MIDDLE); focusMiddle =
focusRight = Drawable.createFromResourceStream(context.getResources(), null, ContextCompat.getDrawable(context, R.drawable.ss_sheetbar_button_focus_middle);
loader.getResourceAsStream(SheetbarResConstant.RESNAME_SHEETBUTTON_FOCUS_RIGHT), // Drawable.createFromResourceStream(context.getResources(), null,
SheetbarResConstant.RESNAME_SHEETBUTTON_FOCUS_RIGHT); // loader.getResourceAsStream(SheetbarResConstant.RESNAME_SHEETBUTTON_FOCUS_MIDDLE),
// SheetbarResConstant.RESNAME_SHEETBUTTON_FOCUS_MIDDLE);
focusRight =
ContextCompat.getDrawable(context, R.drawable.ss_sheetbar_button_focus_right);
// Drawable.createFromResourceStream(context.getResources(), null,
// loader.getResourceAsStream(SheetbarResConstant.RESNAME_SHEETBUTTON_FOCUS_RIGHT),
// SheetbarResConstant.RESNAME_SHEETBUTTON_FOCUS_RIGHT);
} }
public Drawable getDrawable(short resID) public Drawable getDrawable(short resID) {
{ switch (resID) {
switch(resID)
{
case SheetbarResConstant.RESID_SHEETBAR_BG: case SheetbarResConstant.RESID_SHEETBAR_BG:
return sheetbarBG; return sheetbarBG;
case SheetbarResConstant.RESID_SHEETBAR_SHADOW_LEFT: case SheetbarResConstant.RESID_SHEETBAR_SHADOW_LEFT:
return sheetbarLeftShadow; return sheetbarLeftShadow;
case SheetbarResConstant.RESID_SHEETBAR_SHADOW_RIGHT: case SheetbarResConstant.RESID_SHEETBAR_SHADOW_RIGHT:
return sheetbarRightShadow; return sheetbarRightShadow;
case SheetbarResConstant.RESID_SHEETBAR_SEPARATOR_H: case SheetbarResConstant.RESID_SHEETBAR_SEPARATOR_H:
return hSeparator; return hSeparator;
case SheetbarResConstant.RESID_SHEETBUTTON_NORMAL_LEFT: case SheetbarResConstant.RESID_SHEETBUTTON_NORMAL_LEFT:
return normalLeft; return normalLeft;
case SheetbarResConstant.RESID_SHEETBUTTON_NORMAL_MIDDLE: case SheetbarResConstant.RESID_SHEETBUTTON_NORMAL_MIDDLE:
return Drawable.createFromResourceStream(context.getResources(), null, return ContextCompat.getDrawable(context, R.drawable.ss_sheetbar_button_normal_middle);
context.getClassLoader().getResourceAsStream(SheetbarResConstant.RESNAME_SHEETBUTTON_NORMAL_MIDDLE), // return Drawable.createFromResourceStream(context.getResources(), null,
SheetbarResConstant.RESNAME_SHEETBUTTON_NORMAL_MIDDLE); // context.getClassLoader().getResourceAsStream(SheetbarResConstant.RESNAME_SHEETBUTTON_NORMAL_MIDDLE),
// SheetbarResConstant.RESNAME_SHEETBUTTON_NORMAL_MIDDLE);
case SheetbarResConstant.RESID_SHEETBUTTON_NORMAL_RIGHT: case SheetbarResConstant.RESID_SHEETBUTTON_NORMAL_RIGHT:
return normalRight; return normalRight;
case SheetbarResConstant.RESID_SHEETBUTTON_PUSH_LEFT: case SheetbarResConstant.RESID_SHEETBUTTON_PUSH_LEFT:
return pushLeft; return pushLeft;
case SheetbarResConstant.RESID_SHEETBUTTON_PUSH_MIDDLE: case SheetbarResConstant.RESID_SHEETBUTTON_PUSH_MIDDLE:
return pushMiddle; return pushMiddle;
case SheetbarResConstant.RESID_SHEETBUTTON_PUSH_RIGHT: case SheetbarResConstant.RESID_SHEETBUTTON_PUSH_RIGHT:
return pushRight; return pushRight;
case SheetbarResConstant.RESID_SHEETBUTTON_FOCUS_LEFT: case SheetbarResConstant.RESID_SHEETBUTTON_FOCUS_LEFT:
return focusLeft; return focusLeft;
case SheetbarResConstant.RESID_SHEETBUTTON_FOCUS_MIDDLE: case SheetbarResConstant.RESID_SHEETBUTTON_FOCUS_MIDDLE: {
Log.e("SheetbarResManager", "RESID_SHEETBUTTON_FOCUS_MIDDLE");
return focusMiddle; return focusMiddle;
}
case SheetbarResConstant.RESID_SHEETBUTTON_FOCUS_RIGHT: case SheetbarResConstant.RESID_SHEETBUTTON_FOCUS_RIGHT:
return focusRight; return focusRight;
} }
return null; return null;
} }
public void dispose() public void dispose() {
{
sheetbarBG = null; sheetbarBG = null;
sheetbarLeftShadow = null; sheetbarLeftShadow = null;
sheetbarRightShadow = null; sheetbarRightShadow = null;
hSeparator = null; hSeparator = null;
normalLeft = null; normalLeft = null;
normalMiddle = null; normalMiddle = null;
normalRight = null; normalRight = null;
pushLeft = null; pushLeft = null;
pushMiddle = null; pushMiddle = null;
pushRight = null; pushRight = null;
focusLeft = null; focusLeft = null;
focusMiddle = null; focusMiddle = null;
focusRight = null; focusRight = null;
} }
private Context context; private Context context;
private Drawable sheetbarBG; private Drawable sheetbarBG;
private Drawable sheetbarLeftShadow, sheetbarRightShadow; private Drawable sheetbarLeftShadow, sheetbarRightShadow;
private Drawable hSeparator; private Drawable hSeparator;
//left //left
private Drawable normalLeft; private Drawable normalLeft;
private Drawable pushLeft; private Drawable pushLeft;
private Drawable focusLeft; private Drawable focusLeft;
//middle //middle
private Drawable normalMiddle; private Drawable normalMiddle;
private Drawable pushMiddle; private Drawable pushMiddle;
private Drawable focusMiddle; private Drawable focusMiddle;
//right //right
private Drawable normalRight; private Drawable normalRight;
private Drawable pushRight; private Drawable pushRight;
......
/*
* 文件名称: ResConstant.java
*
* 编译器: android2.2
* 时间: 上午11:31:49
*/
package com.wxiwei.office.res;
/**
* 国际化的资源常量
* <p>
* <p>
* Read版本: Read V1.0
* <p>
* 作者: ljj8494
* <p>
* 日期: 2012-8-13
* <p>
* 负责人: ljj8494
* <p>
* 负责小组:
* <p>
* <p>
*/
public class ResConstant
{
//
public static final String BUTTON_OK = "OK";
//
public static final String BUTTON_CANCEL = "Cancel";
//
public static final String DIALOG_ENCODING_TITLE = "Text Encoding";
//
public static final String DIALOG_LOADING = "Loading, please wait...";
//
public static final String DIALOG_INSUFFICIENT_MEMORY = "Unable to complete operation due to insufficient memory";
//
public static final String DIALOG_SYSTEM_CRASH = "System crash, terminate running";
//
public static final String DIALOG_FORMAT_ERROR = "Bad file";
//
public static final String DIALOG_OLD_DOCUMENT = "The document is too old - Office 95 or older, which is not supported";
//
public static final String DIALOG_PARSE_ERROR = "File parsing error";
//
public static final String DIALOG_RTF_FILE = "The document is really a RTF file, which is not supported";
//
public static final String DIALOG_PDF_SEARCHING = "Searching...";
//
public static final String DIALOG_FIND_NOT_FOUND = "Content not found";
//
public static final String DIALOG_FIND_TO_BEGIN = "Search to the document begin";
//
public static final String DIALOG_FIND_TO_END = "Search to the document end";
//
public static final String DIALOG_ENTER_PASSWORD = "Enter Password";
//
public static final String DIALOG_CANNOT_ENCRYPTED_FILE = "Cannot process encrypted file";
//
public static final String DIALOG_PASSWORD_INCORRECT = "Password is incorrect!";
//
public static final String EXIT_SLIDESHOW = "End of slideshow, tap to exit.";
//
public static final String SD_CARD_ERROR = "SD Card Error";
//
public static final String SD_CARD_WRITEDENIED = "SD Card write permission denied";
//
public static final String SD_CARD_NOSPACELEFT = "SD Card has no space left" ;
}
/*
* 文件名称: ResKit.java
*
* 编译器: android2.2
* 时间: 下午9:03:08
*/
package com.wxiwei.office.res;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;
/**
*
* <p>
* <p>
* Read版本: Read V1.0
* <p>
* 作者: ljj8494
* <p>
* 日期: 2012-9-20
* <p>
* 负责人: ljj8494
* <p>
* 负责小组:
* <p>
* <p>
*/
public class ResKit
{
//
private static ResKit kit = new ResKit();
/**
*
*/
public ResKit()
{
try
{
res = new HashMap<String, String>();
// load "ResConstant"
Class cls = Class.forName("com.wxiwei.office.res.ResConstant");
// get all fields
Field[] fields = cls.getDeclaredFields();
for (Field field : fields)
{
res.put(field.getName(), (String)field.get(null));
}
}
catch(Exception e)
{
}
}
/**
*
*/
public static ResKit instance()
{
return kit;
}
/**
*
*/
public boolean hasResName(String resName)
{
return res.containsKey(resName);
}
/**
*
* @param resName
* @return
*/
public String getLocalString(String resName)
{
return res.get(resName);
}
//
private Map<String, String> res;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment